package com.hzd.service;

import ablaze.framework.api.result.ExecuteResult;
import ablaze.framework.service.BaseService;
import com.hzd.entity.RentApplyOrg;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author christ
 * @date 2015/10/23
 */
@Component
@Transactional
public class RentApplyOrgService extends BaseService{


    /**
     * 企业申请
     *
     * @param apply
     * @return
     */
    public ExecuteResult orgApply(RentApplyOrg apply) {

        if (isEmpty(apply)) {
            return failParamNull("申请不能为空");
        }

        if (isEmpty(apply.getName())) {
            return failParamNull("企业名称不能为空");
        }

        if (isEmpty(apply.getContact())) {
            return failParamNull("联系人不能为空");
        }

        if (isEmpty(apply.getContactWay())) {
            return failParamNull("联系方式不能为空");
        }

        if (isEmpty(apply.getStaffNum()) || (apply.getStaffNum().intValue() <= 0)) {
            return failParamInvalidate("员工人数为空或不合法");
        }

        if (entityValidate(apply).fail()) {
            return failParamInvalidate(entityValidate(apply));
        }

        return success(super.storeAndQuery(apply));
    }
}
